/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

API.window = API.window || {};

API.window.BasicWindow = function(config){
    
    API.apply(this, config, {
        title: '',
        items: [],
        buttons: []
    });
    
    //TODO: mejorar esto!!
    this.appended = false;
    
    var title = document.createElement('div');
        title.className = 'window-title';
        title.innerHTML = this.title;
        this.title = title;
    
    var window = document.createElement('div');
        window.className = 'window';
        window.appendChild(title);
        this.window = window;
    
    API.appendItems(this.items, window);
    
    var shadow = document.createElement('div');
        shadow.className = 'window-shadow';
        this.shadow = shadow;
        
};

API.apply(API.window.BasicWindow.prototype,{
    
    getWindow : function(){
        return this.window;
    },
        
    getShadow : function(){
        return this.shadow;
    },
    
    getTitle : function(){
        return this.title;
    },
    
    setTitle : function(value){
        this.title.innerHTML = value;
    },
        
    show : function (){
        
        //if no existe
        if(!this.appended){
            this.appended = true;
            document.body.appendChild(this.getWindow());
            document.body.appendChild(this.getShadow());
        }else{        
            this.getWindow().style.display = "block";
            this.getShadow().style.display = "block";
        }
    },
        
    hide : function(){
        this.getWindow().style.display = "none";
        this.getShadow().style.display = "none";
    }
    
});
